using System;
using System.Collections;

namespace Deepcode.Flux.Core.Extensions.Codons
{
	/// <summary>
	/// Provides a default base implementation for a codon
	/// </summary>
	public abstract class AbstractCodon : ICodon
	{
		/// <summary>
		/// _id is loaded from the id attribute on the tag
		/// </summary>
		[XmlCodonAttribute("id", IsRequired=true)]
		private string _id = null;
		/// <summary>
		/// _class is loaded from the optional class attribute on the tag
		/// </summary>
		[XmlCodonAttribute("class")]
		private string _class = null;
		/// <summary>
		/// _insertafter is loaded from the optional insertafter attribute on the tag
		/// </summary>
		[XmlCodonArrayAttribute("insertafter")]
		private string [] _insertafter = null;
		/// <summary>
		/// _insertbefore is loaded from the optional insertbefore attribute on the tag
		/// </summary>
		[XmlCodonArrayAttribute("insertbefore")]
		private string [] _insertbefore = null;

		/// <summary>
		/// Get the ID of the object as specified in the tag
		/// </summary>
		public string ID
		{
			get{ return _id; }
		}
		/// <summary>
		/// Get the Class of the object as specified in the tag
		/// </summary>
		public string Class
		{
			get{ return _class; }
		}
		/// <summary>
		/// Get/Set the ID that this object should be created before
		/// </summary>
		public string [] InsertBefore
		{
			get{ return _insertbefore; }
			set{ _insertbefore = value; }
		}
		/// <summary>
		/// Get/Set the ID that this object should be created after
		/// </summary>
		public string [] InsertAfter
		{
			get{ return _insertafter; }
			set{ _insertafter = value; }
		}
		/// <summary>
		/// Abstract method to build the object associated with the tag in the addin tree.
		/// </summary>
		/// <param name="owner"></param>
		/// <param name="subItems"></param>
		/// <returns></returns>
		public abstract object BuildItem( object owner, ArrayList subItems );
	}
}
